#include <bits/stdc++.h>

#define in read()
#define fi first
#define se second
#define pb push_back

using namespace std;

using pii = pair < int , int >;
using vec = vector < int >;
using veg = vector < pii >;
using ll = long long;
using db = double;

int read() {
    int x = 0; bool f = 0; char ch = getchar(); while(!isdigit(ch)) f |= ch == '-',ch = getchar();
    while(isdigit(ch)) x = x * 10 + (ch ^ 48),ch = getchar(); return f ? -x : x;
}

const int N = 1e5 + 10;

vec G[N];
int n,a[N],K,ans;

int calc(int x) {
	int res = 0;
	for(auto y : G[x]) { int d = calc(y); if(d == K - 1 && x > 1 || d == K && x == 1) ans++; else res = max(res,d + 1); }
	return res;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("1.in","r",stdin);
#endif
    n = in; K = in; for(int i = 1;i <= n;i++) a[i] = in; for(int i = 2;i <= n;i++) G[a[i]].pb(i);
	ans = a[1] != 1; calc(1); printf("%d\n",ans); return 0;
}
